import requests
from lxml import etree
import random
def get_ips():
    res = requests.get(url="https://www.89ip.cn", headers={
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
        "Referer": "https://cn.bing.com/",
        #这里填写你自己的Cookie
        "Cookie": "https_waf_cookie=945a3d06-d2cb-4359018c2ad5d9c90cced199c96569145c3e; Hm_lvt_f9e56acddd5155c92b9b5499ff966848=1682140313; Hm_lpvt_f9e56acddd5155c92b9b5499ff966848=1682140313"
    })
    res.encoding = "utf8"
    ipItem = etree.HTML(res.text)
    ret = ipItem.xpath('//table[@class="layui-table"]/tbody/tr')
    ips = []
    for linkE in ret:
        ipList = linkE.xpath("./td/text()")
    ip = ipList[0].strip() + ":" + ipList[1].strip()
    ips.append(ip)
    return ips
# import execise_proxy_ip
# import random
# ips=execise_proxy_ip.get_ips()
# res = requests.get("http://httpbin.org/ip",
#                    proxies={
#                        "http":random.choice(ips)
#                    })
# print(res.text)